<%--
  Created by IntelliJ IDEA.
  User: 31324
  Date: 2025/6/16
  Time: 16:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
  <title>Title</title>
  <link rel="stylesheet" href="/layui/css/layui.css">
  <script src="/layui/layui.js"></script>
  <script src="/layui/jquery-3.6.0.min.js"></script>
  <script>
    $(function () {
      layui.use(['laypage', 'layer'], function () {
        var laypage = layui.laypage
                , layer = layui.layer;
      });

      $("#selectAll").click(function () {
        $("input[name='ids']").prop("checked", $(this).prop("checked"))
      })
      $("#addAllIds").click(function () {
        console.log($("td > input[type='checkbox']:checked"))
        var ids = new Array();
        $("td > input[type='checkbox']:checked").each(function () {
          ids.push($(this).val())
        })

        const a = {"rid":${roleId}, "ids": ids};

        $.ajax({
          type: "POST",
          url: "/role/permissionAdd",
          data: JSON.stringify(a),
          contentType: "application/json;charset=utf-8",
          success: function (data) {
            console.log(data)
            location.href = data;
          }
        });

      })

    })

  </script>

</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>权限添加列表</legend>
</fieldset>
<div class="layui-bg-gray" style="padding: 0px;">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-body">

          <div class="layui-btn-group">
            <a class="layui-btn layui-btn-danger layui-btn-sm" id="addAllIds">
              <i class="layui-icon layui-icon-delete"></i>修改权限
            </a>
          </div>
          &nbsp; &nbsp; &nbsp; &nbsp;

        </div>


        <!--数据列表-->
        <table id="dataList" class="layui-table">
          <thead>
          <tr>
            <th class="" style="padding-right: 0px;">

              <input id="selectAll" type="checkbox" class="icheckbox_square-blue">
            </th>
            <th>ID</th>
            <th>权限名称</th>
            <th>权限地址</th>
          </tr>
          </thead>
          <tbody>
          <c:forEach items="${permissionList}" var="permission">
            <tr>
              <td><input name="ids" type="checkbox" value="${permission.id}"
              <c:forEach items="${permissionIdList}" var="i">
              <c:if test="${i.id== permission.id}">
                         checked
              </c:if>
              </c:forEach>
              >
              </td>

              <td>${permission.id}</td>
              <td>${permission.permissionName}</td>
              <td>${permission.url}</td>

            </tr>
          </c:forEach>
          </tbody>
        </table>

      </div>
    </div>
  </div>
</div>
</div>
</body>
</html>
